<?php 
@session_start();
require_once('config/config.php');
require_once('utils/CommonUtils.php');
require_once('utils/DBUtils.php');
include ("utils/Constants.php");
require_once('utils/BaseDAO.php');
require("utils/Session.php"); 

$commonUtils = new CommonUtils();
$baseDAO = new BaseDAO();
$latestContents = $baseDAO->getItems("content", array("id", "image", "title", "brief", "createdby", "createddate"), "status = 1", "order by createddate desc", 0, 1);
$contents = $baseDAO->getItems("content", array("id", "image", "title", "brief", "createdby", "createddate"), "status = 1", "order by createddate desc", 1, 4);
$hotimages = $baseDAO->getItems("image", array("id", "image", "title", "createddate", "createdby"), "status=1", "order by createddate desc", 0, 15);
$youtubes = $baseDAO->getItems("youtube", array("id", "src", "title", "createddate", "createdby"), "status=1", "order by createddate desc", 0, 2);
?>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<LINK REL="SHORTCUT ICON" HREF="img/fm.ico"> 
		<title>Nguyễn Đậu - Trang chủ</title>
		<link rel="stylesheet" type="text/css" href="css/style.css"/>
		<link rel="stylesheet" type="text/css" href="css/jquery.fancybox.css"/>
		<link rel="stylesheet" type="text/css" href="css/jcarousel.css"/>
		<link href="css/bootstrap.css" rel="stylesheet">
				
		<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>
		<script type="text/javascript" src="js/jquery.fancybox.js"></script>
		<script type="text/javascript" src="js/jquery.jcarousel.min.js"></script>
		<script type="text/javascript" src="js/jquery.hind.js"></script>
		<script type="text/javascript" src="js/jquery.corner.js"></script>
		
	</head>
	<body>
<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/vi_VN/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
		<div id="content">
			<div id="header">
				<span id="text"><img src="images/nguyendau.jpg"/></span>
				<span id="login">
					<?php if(Session::get('fullname') != null && Session::get('fullname') != ""){?>
						<span style="color:#000;">Xin chào</span>&nbsp;<img src="css/images/user.png"/>&nbsp;<?php echo Session::get('fullname');?>
						| <a href="admin/content-list.html"><img src="css/images/cog.png"/>&nbsp;Quản trị</a>
						| <a href="login.html?action=logout"><img src="css/images/stop.png"/>&nbsp;Thoát</a>
					<?php }else{?>
						<a href="login.html">Đăng nhập</a>
					<?php }?>
				</span>
				
				<div class="menu">
					
					<a href="./">Trang chủ</a>
					<a href="./bai-viet">Bài viết</a>
					<a href="./hinh-anh">Hình ảnh</a> 
					<a href="./video">Video</a>
					
				</div>
			</div>
			
			<div id="page">
				<div id="hotcontent">
					<div id="col1">
						<?php foreach ($latestContents as $latestContent){ ?>
							<div class="image"><a href="<?php echo './bai-viet/chi-tiet.php?id='.$latestContent['id'];?>"><img src="<?php echo 'images/content/'.$latestContent['image'];?>" width="580px" height="400px"/></a></div>
							<div class="title"><a href="<?php echo './bai-viet/chi-tiet.php?id='.$latestContent['id'];?>"><?php echo $latestContent['title'];?></a></div>
							<div class="brief"><?php echo $latestContent['brief'];?></div>
							<div class="createdby">
								<?php echo $latestContent['createdby'];?>
								<span class="displayDate"><?php echo $commonUtils->timePost($latestContent['createddate']);?></span>
							</div>
						<?php }?>
					</div>
					<div id="col2">
						<?php foreach ($contents as $content){ ?>
							<div class="hostpost">
								<div id="img"><img src="<?php echo 'images/content/thumb/'.$content['image'];?>" width="120px"/></div>
								<div id="detail">
									<div id="title" class="title"><a href="<?php echo './bai-viet/chi-tiet.php?id='.$content['id'];?>"><?php echo $content['title'];?></a></div>
									<div id="brief"><?php echo $content['brief'];?></div>
									<div id="author">
										<span class="createdby"><?php echo $content['createdby'];?></span>
										<span class="displayDate"><?php echo $commonUtils->timePost($content['createddate']);?></span>
									</div>
								</div>
							</div>
						<?php }?>
					</div>
				</div>
				<div style="clear:both"></div>
				<div id="hotimage">
					<ul id="mycarousel" class="jcarousel-skin-tango">
					<?php foreach ($hotimages as $image){?>
						<li>
							<div id="img">
								<a href="ajax/loadimage.php?id=<?php echo $image['id']; ?>" class="fancybox"  ><img src="images/images/thumb/<?php echo $image['image'];?>"/></a>
								<div class="title" style="height:38px;overflow:hidden"><a href="ajax/loadimage.php?id=<?php echo $image['id']; ?>" class="fancybox" ><?php echo $image['title'];?></a></div>
							</div>
						</li>
					<?php }?>
					</ul>
					<div style="clear:both"></div>
				</div>
				<div style="clear:both"></div>
				<?php foreach ($youtubes as $youtube){?>
					<div class="span6 well" style="margin-left:5px;width:430px;float:left;">
						<div id="title" class="title"><?php echo $youtube['title'];?></div>
						<iframe width="432" height="315" src="<?php echo $youtube['src'];?>" frameborder="0" allowfullscreen></iframe>
					</div>
				<?php }?>
				<div style="clear:both"></div>
			</div>
			<?php include 'include/webfooter.php';?>
		</div>
	</body>
	
<script type="text/javascript">
$(document).ready(function(){
	$(".fancybox").fancybox({
		type: 'ajax',
		width: '1000px',
		afterShow: function(){
			$("#txtCommentImage").hint();
		}
	});
	$('#mycarousel').jcarousel({
		 scroll: 5,
		 wrap: 'circular'
	});
	$('.myCorner').corner();
	
	$(".hostpost").hover(function(){
		$(this).addClass("hostpost_");
	}, function(){
		$(this).removeClass("hostpost_");
	});
});
</script>
</html>

